| Conditions | 3 |
| Total Lines | 13 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | /** |
||
| 2 | * Return object which is a shallow merge of 'target' and 'source'. Written manually bacause: |
||
| 3 | * - {...target, ...source} does not work with generic types (https://github.com/Microsoft/TypeScript/issues/22687) |
||
| 4 | * - Object.assign does not work in IE <= 11 |
||
| 5 | */ |
||
| 6 | function merge<T extends {}, U extends {}>(target: T, source: U): T & U { |
||
| 7 | const newObj = Object.create(target); |
||
| 8 | for (const key in source) { |
||
| 9 | if (source.hasOwnProperty(key)) { |
||
| 10 | newObj[key] = source[key]; |
||
| 11 | } |
||
| 12 | } |
||
| 13 | return newObj; |
||
| 14 | } |
||
| 36 |